from typing import Optional, List
import os
# from langchain_core.prompts import ChatPromptTemplate
# from langchain_community.chat_models import QianfanChatEndpoint


from langchain.prompts import ChatPromptTemplate
from langchain.chat_models import QianfanChatEndpoint

AK = '2jCwbiCWReSVlPbt53f9pYhP'
SK = 'dwJ8BULLCsBMXsmtjyxNI8hkw4y0HPXq'
os.environ['QIANFAN_AK'] = AK
os.environ['QIANFAN_SK'] = SK
template_str = '''
您是一位专业的鲜花店文案撰写员。\n
对于售价为 {price} 元的 {flower_name} ，您能提供一个吸引人的简短描述吗？
注意: 文字不要超过50个字符 
'''
prompt_emplate = ChatPromptTemplate.from_template(template_str)
prompt = prompt_emplate.format_messages(flower_name=['玫瑰'], price='50')
print('prompt-->', prompt)
chat = QianfanChatEndpoint(streaming=True, model='Qianfan-BLOOMZ-7B-compressed')
print(chat(prompt))
